package gogs_hook

import "atomgit.com/openlinksaas-org/proto-gen-go.git/events/events_gogs"

type IssueCommentHook struct {
	Action     string      `json:"action"`
	Issue      *Issue      `json:"issue"`
	Comment    *Comment    `json:"comment"`
	Changes    *Changes    `json:"changes,omitempty"`
	Repository *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

func (item *IssueCommentHook) ToProtoBuf() *events_gogs.IssueCommentEvent {
	ret := &events_gogs.IssueCommentEvent{
		Action:     item.Action,
		Issue:      []*events_gogs.Issue{},
		Comment:    []*events_gogs.Comment{},
		Changes:    []*events_gogs.Changes{},
		Repository: []*events_gogs.Repository{},
		Sender:     []*events_gogs.User{},
	}
	if item.Issue != nil {
		ret.Issue = append(ret.Issue, item.Issue.ToProtoBuf())
	}
	if item.Comment != nil {
		ret.Comment = append(ret.Comment, item.Comment.ToProtoBuf())
	}
	if item.Changes != nil {
		ret.Changes = append(ret.Changes, item.Changes.ToProtoBuf())
	}
	if item.Repository != nil {
		ret.Repository = append(ret.Repository, item.Repository.ToProtoBuf())
	}
	if item.Sender != nil {
		ret.Sender = append(ret.Sender, item.Sender.ToProtoBuf())
	}
	return ret
}
